home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!usenet
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: Inheritance: Accessing members of base classes for assignment in derived classes
- Date: Wed, 10 Apr 1996 01:44:40 GMT
- Organization: InfoRamp Inc., Toronto, Ontario (416) 363-9100
- Message-ID: <4kep9o$6ci@sam.inforamp.net>
- References: <4k7cv8$h4m@dfw-ixnews5.ix.netcom.com>
- NNTP-Posting-Host: ts11-09.tor.istar.ca
- X-Newsreader: Forte Free Agent 1.0.82
-
- guerino1@ix.netcom.com(Frank Guerino ) wrote:
-
- > Instruction& Instruction::operator=(const Instruction& x){
- > char *tmp;
- > strcpy(tmp, x.get_instruct());
-
- Note that x is a const class and get_instruct is not a const member.
- When you have a const class you can only access const members. Thus,
- you have to make the function const also, try...
- char *get_instruct() const { return String::get(); }
- and the save would go for the get statement...
- char *get() const { return str; }
-
- Hope this solves your problem.
-
-
- Agrivar
-
- aka Randy Charles Morin,
- MiddleWorld SoftWare,
- Satisfying Your Bit and Bytes,
- Canada 1-800-363-3780
- Other 1-905-279-2087
- eMail rmorin@inforamp.net
-
-